//1. 引入核心包
import React from 'react'
import { NavBar } from 'antd-mobile'
import { withRouter } from 'react-router-dom'
import PropTypes from 'prop-types'
import styles from './index.module.scss'

//2. 类组件
class NavHeader extends React.Component {
  render() {
    const { children } = this.props
    return (
      <div className={styles.navbar}>
        <NavBar
          mode="light"
          icon={<i className="iconfont icon-back"></i>}
          onLeftClick={() => this.props.history.go(-1)}
        >
          {children}
        </NavBar>
      </div>
    )
  }
}

NavHeader.propTypes = {
  children: PropTypes.string.isRequired
}

export default withRouter(NavHeader)
